<?php
include_once ('global.php');

$sql = "SELECT * FROM `p_newsclass` where f_id=0 order by id DESC";
$query = $db->query($sql);
while ($row_class = $db->fetch_array($query)) {
	$sm_class[] = array (
		"name" => $row_class[name],
		"id" => $row_class[id]
	);
}

$smarty->assign("sm_class", $sm_class); //导航引入

//==============

$sql = "SELECT * FROM p_config";
$query = $db->query($sql);
while ($row_config = $db->fetch_array($query)) {
	$sm_config[] = $row_config[values];
}

$smarty->assign("sm_config",$sm_config); //配置引入

//==============
$sql="SELECT `cid`FROM `p_newsbase`WHERE `id` ='$_GET[id]'";
    $query=mysql_query($sql);
    $row_classnameid=mysql_fetch_array($query);
 $sql="SELECT `name`FROM `p_newsclass`WHERE `id` ='$row_classnameid[0]'";
    $query=mysql_query($sql);
    $row_newsclass=mysql_fetch_array($query);
if(!empty($_GET[id])){
	$sql="select * from p_newsbase as a, p_newscontent as b where a.id=b.nid and a.id='$_GET[id]'";
    $query=mysql_query($sql);
    $row_news=mysql_fetch_array($query);
    $row_news[4]=date("m-d h:m",$row_news[4]);
    if($row_news[12]==NULL)
    $row_news[12]="没有填写QQ号";
    $row_news[15]=$row_newsclass[0];

}
//内容访问量的计算
$click=$row_news[click]+1;
$db->query("update `p_newscontent` set click='$click'  where nid='$row_news[0]'");

$smarty->assign("row_news",$row_news);


$sql="SELECT * FROM `number`";
 $query=$db->query($sql);
$number=$db->fetch_array($query);//获取全部数字；
$smarty->assign("number",$number);
$smarty->display("view_test.htm");

?>
